{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "99f01bdd",
   "metadata": {},
   "source": [
    "These pip installs need to be adapted to use the appropriate release level. Alternatively, The venv running the jupyter lab could be pre-configured with a requirement file that includes the right release. Example for transform developers working from git clone:\n",
    "\n",
    "    make venv \n",
    "    source venv/bin/activate \n",
    "    pip install jupyterlab"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1175677d",
   "metadata": {},
   "outputs": [],
   "source": [
    "%%capture\n",
    "## This is here as a reference only\n",
    "# Users and application developers must use the right tag for the latest from pypi\n",
    "%pip install data-prep-toolkit[ray]\n",
    "%pip install data-prep-toolkit-transforms[license_select]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "06ba22af",
   "metadata": {},
   "outputs": [],
   "source": [
    "from dpk_license_select.ray import LicenseSelect"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "5957a088-10a0-41fd-9b82-c329f088f2c8",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "15:42:21 INFO - Running locally\n",
      "15:42:21 INFO - data factory lc_ is using local configuration without input/output path\n",
      "15:42:21 INFO - data factory lc_ max_files -1, n_sample -1\n",
      "15:42:21 INFO - data factory lc_ Not using data sets, checkpointing False, max files -1, random samples -1, files to use ['.parquet'], files to checkpoint ['.parquet']\n",
      "15:42:21 INFO - Getting supported licenses from file ./test-data/sample_approved_licenses.json\n",
      "15:42:21 INFO - Read a list of 171 licenses.\n",
      "15:42:21 INFO - data factory data_ is using local data access: input_folder - ./test-data/input output_folder - output\n",
      "15:42:21 INFO - data factory data_ max_files -1, n_sample -1\n",
      "15:42:21 INFO - data factory data_ Not using data sets, checkpointing False, max files -1, random samples -1, files to use ['.parquet'], files to checkpoint ['.parquet']\n",
      "15:42:21 INFO - pipeline id pipeline_id\n",
      "15:42:21 INFO - code location None\n",
      "15:42:21 INFO - number of workers 1 worker options {'num_cpus': 0.8, 'max_restarts': -1}\n",
      "15:42:21 INFO - actor creation delay 0\n",
      "15:42:21 INFO - job details {'job category': 'preprocessing', 'job name': 'license_select', 'job type': 'ray', 'job id': 'job_id'}\n",
      "2025-02-13 15:42:21,811\tINFO worker.py:1568 -- Connecting to existing Ray cluster at address: 127.0.0.1:6379...\n",
      "2025-02-13 15:42:21,815\tINFO worker.py:1744 -- Connected to Ray cluster. View the dashboard at \u001b[1m\u001b[32m127.0.0.1:8265 \u001b[39m\u001b[22m\n",
      "\u001b[36m(orchestrate pid=65550)\u001b[0m 15:42:21 INFO - orchestrator started at 2025-02-13 15:42:21\n",
      "\u001b[36m(orchestrate pid=65550)\u001b[0m 15:42:21 ERROR - No input files to process - exiting\n",
      "15:42:31 INFO - Completed execution in 0.16988400220870972 min, execution result 0\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "LicenseSelect(\n",
    "        input_folder = \"./test-data/input\",\n",
    "        output_folder = \"output\",\n",
    "        lc_licenses_file = \"./test-data/sample_approved_licenses.json\",\n",
    "        run_locally = True\n",
    "    ).transform()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "024b6462",
   "metadata": {},
   "source": [
    "***** Use ray runtime to invoke the transform\n",
    "**** The specified folder will include the transformed parquet files."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "81b94ade",
   "metadata": {},
   "outputs": [],
   "source": [
    "import glob\n",
    "glob.glob(\"output/*\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "78b38f2e",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
